package trajectories;

public class SquareTrajectorie extends Trajectory {
    private Directions CURRENT_DIRECTION = Directions.DOWN;

    private int count = 0;

    @Override
    public void move() {
        switch (CURRENT_DIRECTION) {
            case DOWN:
                count++;
                y++;
                if (count == 60) {
                    count = 0;
                    CURRENT_DIRECTION = Directions.RIGHT;

                }
                break;
            case UP:
                count++;
                y--;
                if (count == 60) {
                    count = 0;
                    CURRENT_DIRECTION = Directions.LEFT;

                }
                break;
            case RIGHT:
                count++;
                x++;
                if (x == 400) {
                    CURRENT_DIRECTION = Directions.UP;
                    TRAJECTORY_DIRECTION = Directions.LEFT;
                    count = 0;
                }
                if (count == 60) {
                    count = 0;
                    CURRENT_DIRECTION = Directions.UP;

                    switch (TRAJECTORY_DIRECTION) {
                        case RIGHT:
                            x += 10;
                            break;
                        case LEFT:
                            x -= 10;
                            break;
                    }
                }

                break;

            case LEFT:
                count++;
                x--;
                if (x == 100) {
                    CURRENT_DIRECTION = Directions.DOWN;
                    TRAJECTORY_DIRECTION = Directions.RIGHT;
                    count = 0;
                }
                if (count == 60) {
                    count = 0;
                    CURRENT_DIRECTION = Directions.DOWN;

                    switch (TRAJECTORY_DIRECTION) {
                        case RIGHT:
                            x += 10;
                            break;
                        case LEFT:
                            x -= 10;
                            break;
                    }
                }

                break;
        }

    }

}
